package org.study.neo4j.boot.controller;

import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.study.neo4j.boot.service.RelationshipService;

/**
 * 作用描述
 *
 * @author doveylovey
 * @version v1.0.0
 * @email 1135782208@qq.com
 * @date 2025年04月09日
 */
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
@RestController
@RequestMapping("/api/relationships")
public class RelationshipController {
    private final RelationshipService relationshipService;

    @PostMapping("/enroll")
    public void enrollStudentInCourse(@RequestParam(name = "studentId") Long studentId,
                                      @RequestParam(name = "courseCode") String courseCode) {
        relationshipService.enrollStudentInCourse(studentId, courseCode);
    }

    @PostMapping("/assign-teacher")
    public void assignTeacherToCourse(@RequestParam(name = "teacherId") Long teacherId,
                                      @RequestParam(name = "courseCode") String courseCode) {
        relationshipService.assignTeacherToCourse(teacherId, courseCode);
    }

    @PostMapping("/assign-advisor")
    public void assignAdvisorToStudent(@RequestParam(name = "teacherId") Long teacherId,
                                       @RequestParam(name = "studentId") Long studentId) {
        relationshipService.assignAdvisorToStudent(teacherId, studentId);
    }

    @DeleteMapping("/unenroll")
    public void removeStudentFromCourse(@RequestParam(name = "studentId") Long studentId,
                                        @RequestParam(name = "courseCode") String courseCode) {
        relationshipService.removeStudentFromCourse(studentId, courseCode);
    }
}
